import java.util.Comparator;
import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2024-09-26
 * Time: 19:59
 */
class Card implements Comparable<Card>{
    public String suit;
    public int rank;

    public Card(String suit, int rank) {
        this.suit = suit;
        this.rank = rank;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Card card = (Card) o;
        return rank == card.rank && Objects.equals(suit, card.suit);
    }

    @Override
    public int hashCode() {
        return Objects.hash(suit, rank);
    }

    @Override
    public int compareTo(Card o) {
        return this.rank - o.rank;
    }

    @Override
    public String toString() {
        return "Card{" +
                "suit='" + suit + '\'' +
                ", rank=" + rank +
                '}';
    }
}

class SuitComparator implements Comparator<Card>{
    @Override
    public int compare(Card o1, Card o2) {
        return o1.suit.compareTo(o2.suit);
    }
}

public class Test2 {
    public static void main(String[] args) {
        Card card1 = new Card("hongtao", 15);
        Card card2 = new Card("heitao", 5);
        if(card1.compareTo(card2) > 0){
            System.out.println("card1 > card2");
        }else{
            System.out.println("card1 < card2");
        }
        System.out.println("========");
        SuitComparator suitComparator = new SuitComparator();
        if(suitComparator.compare(card1,card2) > 0){
            System.out.println("card1 > card2");
        }else{
            System.out.println("card1 < card2");
        }

    }

    public static void main1(String[] args) {
        Card card1 = new Card("红桃", 5);
        Card card2 = new Card("红桃", 5);

        System.out.println(card1.equals(card2));
    }
}
